﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;

public partial class my_new_edit : AdminpageBase
{
    protected string ctype = ReadRequest.RequestString("t");
    protected long id = ReadRequest.RequestLong("id");
    protected Model.GoldCode model = new Model.GoldCode();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }
    }
    private long IsExit(string nickename)
    {
        Model.CMember model = BLL.CMember.GetOneBynickname(nickename);
        return model != null ? model.Id : 0;
    }
    private bool IsNumber(string value)
    {
        // return System.Text.RegularExpressions.Regex.IsMatch(value, @"^[A-Za-z]+$");
        return Regex.Match(value, "^\\d+$").Success;
    }
    //提交按钮事件
    protected void btn_submit_Click(object sender, EventArgs e)
    {
        save_Newscont();
    }
    private void save_Newscont()
    {
        //获取登录信息
        Model.Manageadmin loginUserInfo_cur = BLL.CMember.ManageadminLoginInfo();
        //没有登录
        if (loginUserInfo_cur == null)
        {
            alertmessageAndGoback("保存失败");
            return;
        }
        Model.LotteryBuyDetail model = new Model.LotteryBuyDetail();
        int userid=int.Parse(IsExit(nicknametxt.Text).ToString());
        if (userid == 0)
        {
            alertmessageAndGoback("该用户不存在");
            return;
        }
        model.User_id = userid;
        model.LotteryType = int.Parse(caipiaoType.SelectedValue);
        model.LotteryQs = textQS.Text;
        model.LotteryNo = txtNo.Text;
        model.LotteryCount = long.Parse(couttxt.Text);
        model.LotteryMultiple = int.Parse(Multitxt.Text);

        model.LotteryMoney = model.LotteryCount * 2 * model.LotteryMultiple;
        model.IsWin = false;
        model.WinLevel = -1;
        model.WinMoney = 0;
        model.AddTime = DateTime.Now;
        model.lotteryPlay = "0";
        model.Flag = false;
        model.fcType = int.Parse(fcTypetxt.Text);
        model.IsOpen = 1;
        model.secret = "赠送";


        long createid = BLL.LotteryBuyDetail.Add(model);
        if (createid > 0)
        {
            alertmessageAndGo("保存成功！", "/manage/Giving/givelist.aspx");
            return;
        }
        else
        {
            alertmessageAndGoback("保存失败");
            return;
        }
    }
}